#@head() #@header()
<title>融资需求管理</title>
#@aside("marketing")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
			#@appmenu("pushmessage")
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				 <div class="box-body" style="width:50%">
					<table id="example1" class="table table-bordered table-striped dataTable col-md-8" role="grid" aria-describedby="example1_info">
						<tbody>
						<tr role="row" id="zd_user"  class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">标题</td>
						  <td  class="sorting_1">
							<textarea id="title" rows="1" cols="80"></textarea>
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">内容</td>
						  <td class="sorting_1">
							<textarea id="contents" rows="10" cols="80"></textarea>
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:130px;" class="sorting_1">发送对象</td>
						  <td  class="sorting_1">
							<select id="type" class="form-control">
								<option value="all">全部</option>
								<option value="ios">IOS</option>
								<option value="android">android</option>
							</select>
						  </td>
						</tr>
						
						</tbody>
					</table>
				</div>
				<button type="button" id="submitbt" class="btn bg-olive margin">提交</button>
              </div>
            </div>
            <!-- /.tab-content -->
          </div>
		  
	</section>
</div>
#@footer()
<script>
	$("#submitbt").click(function(){
		var title = $("#title").val();
		var contents = $("#contents").val();
		var type = $("#type").val();
		layer.confirm('确认发送推送？', {
		  btn: ['确认','取消'] //按钮
		}, function(){
			layer.msg('发送中',function(){
				$.getJSON("/app/push?token=#(session.token??)&title="+title+"&type="+type+"&contents="+contents, function(pushmessage) {
					console.log(pushmessage);
					if(pushmessage.code=='success'){
						layer.msg("发送成功", {icon:1},function(){
							location.href="#(path)/admin/page/marketing-pushmessage"
						}); 
					}else if(pushmessage.code=='error'){
						layer.msg(pushmessage.msg, {icon : 2});
					}
				});	
			});
		}, function(){
			layer.msg('已取消', {icon: 2});
		});	
	});
</script> 

</body>
</html>

